<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <input type="text">
    <input type="text">
    <button>登录</button>

    <script>
        var inputs = [...document.querySelectorAll("input")],
            btn = document.querySelector("button"),
            regUser = /^([\u4e00-\u9fa5]{2,4}|1[3-9]\d{9}|\w+@\w+\.com)$/,
            regPwd = /^[0-9a-zA-Z]{6,12}$/



        btn.addEventListener("click", function () {
            if (regUser.test(inputs[0].value) && regPwd.test(inputs[1].value)) {
                alert("OK")
            } else {
                alert("NO")
            }
        })


    </script>
</body>

</html>